<?php
/**
* $Id: login.php 2942 2009-11-30 10:48:18Z huong.pham $
*/
?>
<div class="LoginForm">    
    <h1>TriVu Technologies</h1>
    <form id="loginForm" method="post" style="<?php if($this->uri->uri_string != '/admin/login') echo "display:none"?>">
        <fieldset>
            <h2 class="Title">Login</h2>
            <?=$this->validation->error_string;?>
            
            <div class="Input">
                <label for="username">User name:</label><br/>
                <input type="text" id="email" name="email" class="Text required" size="64" />
            </div>
            <div class="Input">
                <label for="password">Password:</label><br/>
                <input type="password" id="password" name="password" class="Text required" size="300" />
            </div>
            <div class="Output">
                <input type="submit" value="Sign in" class="Button" />
                <a href="#" title="Forgot password" class="ForgotPassword" id="linkForgotPassword">Forgot password</a>
            </div>
        </fieldset>
    </form>
    <!-- forgotPassword -->
   <form action="<?=site_url('admin/lostpassword')?>" id="forgotPassword" style="<?php if($this->uri->uri_string != '/admin/lostpassword') echo "display:none"?>" method="post">  
        <fieldset>
            <h2>Forgot Password ?</h2>
            <?=$this->validation->error_string;?>
            <div class="Input">
                <label for="userEmail">Email:</label>
                <input type="text" id="userEmail" name="userEmail" class="Text required email" maxlength="64"/>
            </div>
            <div class="Output">
                <input type="submit" value="Submit" class="Button"/>
                <a title="Return Login ?" href="#" class="ForgotPassword" id="linkReturnLogin">&gt; Return Login ?</a>
            </div>
        </fieldset>
    </form>
    <!-- forgotPassword.end -->
</div>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
    
    //Validation login form 
    $("#loginForm").validate(
        {
            errorElement: "em",
            errorClass: 'Error',
            messages: {
                'username': {
                    required: '*'
                },
                'password': {
                    required: '*'
                }
            }
        }
      );
      
    // Remove server error message when client validation is failed
    $("#loginForm #email_login").change(function() {
        if (!$("#loginForm").valid()) {
            if ($("#loginForm em.Error[id!='serverError'][generated='true']").length > 0) {
                $("#loginForm em#serverError").hide();
            }
        }    
    }); 
    
    //Show forgot password form
    $("#linkForgotPassword").click(function() { 
        $("#loginForm").hide();   
        $("#forgotPassword").show(); 
        return false;  
    }); 
    
    //Show login form
    $("#linkReturnLogin").click(function() { 
        $("#loginForm").show();   
        $("#forgotPassword").hide(); 
        return false;  
    }); 
    
    //Forgot password validation
    $("#forgotPassword").validate(
        {
            errorElement: "em",
            errorClass: 'Error',
            messages: {
                'userEmail': {
                    required: '*'
                }
            }            
        }
     ); 
}
);

/* ]]> */
</script>